﻿Module Module1

    'Private Function comparar(ByVal arr() As String) As String
    '    For i as integer to arr.length

    '    Next

    'End Function

    'Public num As String

    Sub Main()
        Console.Title = "Ejercicio bucle 5"

        Dim numArray() As Integer
        Dim seguir, numSr As String
        Dim cont, contnum As Integer
        contnum = 1
        ReDim Preserve numArray(1)
        Console.WriteLine("Introduce numeros de positivos y te dire cual es el mayor")

        Do
            Console.Write("Nº " & contnum & " ")
            numSr = Console.ReadLine()

            Do While Not IsNumeric(numSr) ' OrElse Integer.Parse(numSr) < 0
                Console.WriteLine("No es un numero o es negativo vuelva a introducirlo  ")
                Console.Write("Nº " & contnum & " ")
                numSr = Console.ReadLine()

            Loop
            contnum += 1
            numArray(cont) = Integer.Parse(numSr)
            Console.Write("Desea continuar (S/N) ")
            seguir = Console.ReadLine()
            cont += 1
            ReDim Preserve numArray(cont)


        Loop Until seguir.ToUpper = "N"
        Array.Sort(numArray)
        If numArray(cont) = 0 Then
            Console.WriteLine("El mayor es " & numArray(cont - 1))
        Else
            Console.WriteLine("El mayor es " & numArray(cont))
        End If
        Console.ReadKey()

    End Sub

End Module
